from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column
from sqlalchemy import Integer, String, SmallInteger
from ..database.db import Base  # 假设这是你的数据库基类导入方式

class Images(Base):
    __tablename__ = 'images'  # 这里假设表名为 'images'

    id: Mapped[int] = mapped_column(Integer, primary_key=True, autoincrement=True)
    name: Mapped[str] = mapped_column(String(255), nullable=False)
    path: Mapped[str] = mapped_column(String(255), nullable=False)
    type: Mapped[int] = mapped_column(SmallInteger, nullable=True)  # 添加 type 字段
    oss_url: Mapped[str] = mapped_column(String(255), nullable=True)

    def as_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}